package com.houweishi.module.history.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.history.domain.BizWorkHistory;
import com.houweishi.module.history.service.IBizWorkHistoryService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 员工工作经历Controller
 * 
 * @author houweishi
 * @date 2023-02-21
 */
@RestController
@RequestMapping("/module/history")
public class BizWorkHistoryController extends BaseController
{
    @Autowired
    private IBizWorkHistoryService bizWorkHistoryService;

    /**
     * 查询员工工作经历列表
     */
    @PreAuthorize("@ss.hasPermi('module:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizWorkHistory bizWorkHistory)
    {
        startPage();
        List<BizWorkHistory> list = bizWorkHistoryService.selectBizWorkHistoryList(bizWorkHistory);
        return getDataTable(list);
    }

    /**
     * 导出员工工作经历列表
     */
    @PreAuthorize("@ss.hasPermi('module:history:export')")
    @Log(title = "员工工作经历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizWorkHistory bizWorkHistory)
    {
        List<BizWorkHistory> list = bizWorkHistoryService.selectBizWorkHistoryList(bizWorkHistory);
        ExcelUtil<BizWorkHistory> util = new ExcelUtil<BizWorkHistory>(BizWorkHistory.class);
        util.exportExcel(response, list, "员工工作经历数据");
    }

    /**
     * 获取员工工作经历详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizWorkHistoryService.selectBizWorkHistoryById(id));
    }

    /**
     * 新增员工工作经历
     */
    @PreAuthorize("@ss.hasPermi('module:history:add')")
    @Log(title = "员工工作经历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizWorkHistory bizWorkHistory)
    {
        return toAjax(bizWorkHistoryService.insertBizWorkHistory(bizWorkHistory));
    }

    /**
     * 修改员工工作经历
     */
    @PreAuthorize("@ss.hasPermi('module:history:edit')")
    @Log(title = "员工工作经历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizWorkHistory bizWorkHistory)
    {
        return toAjax(bizWorkHistoryService.updateBizWorkHistory(bizWorkHistory));
    }

    /**
     * 删除员工工作经历
     */
    @PreAuthorize("@ss.hasPermi('module:history:remove')")
    @Log(title = "员工工作经历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizWorkHistoryService.deleteBizWorkHistoryByIds(ids));
    }
}
